﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowFloorPaper.aspx.cs"
    Inherits="ZLDC.Estate.TM.ShowFloorPaper" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>看楼纸明细</title>
    <base target="_self" />
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../js/jquery/style/jquery.hiAlerts.css" rel="stylesheet" type="text/css" />

    <script src="../js/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="../js/LexunJS.js" type="text/javascript"></script>

    <script src="../js/jShowDiv.js" type="text/javascript"></script>

    <script src="../js/jquery/jquery.hiAlerts-min.js" type="text/javascript"></script>

    <link href="../js/jquery.autocomplete/jquery.autocomplete.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        var currentPage = 1; // 当前页
        var pageSize = 15; // 每页显示多少条
        var pageall = 0; // 总页数
        var total = 0; // 总记录数
        var type_Id = 0; ///操作类型，0查询看楼纸，1取回看楼纸
        // 读取列表
        $(function() {
            type_Id = LexunJS.GetQueryString("typeId");
            if (type_Id == 1) {
                $("#btnSave").hide();
            } else {
                $("#btnSave").show();
            }
            showList(currentPage);

        });

        // 条件查询资源列表
        function showList(currentPage) {
            var user_id = LexunJS.GetQueryString("userId");



            $("#divList").html("<img src=\"../images/loading.gif\" />"); // 清空列表
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerCustomer.ashx',
                data: 'act=ShowFloorPaper_list&page=' + currentPage + '&pagesize=' + pageSize + '&userId=' + user_id,
                timeout: '10000',
                error: function() {
                    alert("系统繁忙,请稍候后试！");
                }, success: function(json) {
                    listCallBack(json);
                }
            });
        }

        function listCallBack(response) {
            var json = eval("(" + response + ")");
            var record = json.record;

            if (record == null || record.length == 0) {
                $("#divList").html("<font color='red'>&nbsp;系统内暂无您查询的信息!</font>");
                $("#divPage").html("");
                return;
            }

            var page = json.page;

            currentPage = page.currentpage;
            pageall = parseInt(page.pageall);
            total = page.total;


            var arr = [];
            arr.push("<table id='table1' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
            arr.push("<tr>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("<input type=\"checkbox\" name=\"checkboxAll\" id=\"checkboxAll\" onclick=\"cbSelectAll()\" />");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("序号");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("看楼纸编号");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("使用状态");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("分配人员");
            arr.push("</td>");

            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("分配时间");
            arr.push("</td>");

            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("所属人员");
            arr.push("</td>");

            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("使用时间");
            arr.push("</td>");


            arr.push("</tr>");


            var recordLength = record.length;
            for (var i = 0; i < recordLength; i++) {

                if (type_Id == 0) {
                    if (i % 2 == 0)
                        arr.push("<tr id='tr_" + record[i].id + "'  bgcolor='#FFFFFF' style='cursor: pointer;' onclick=\"selectedTr('" + record[i].id + "')\">");
                    else
                        arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED' style='cursor: pointer;' onclick=\"selectedTr('" + record[i].id + "')\">");
                } else {
                if (i % 2 == 0)
                        arr.push("<tr id='tr_" + record[i].id + "'  bgcolor='#FFFFFF' style='cursor: pointer;' ondblclick=\"ReturnValue('" + record[i].paperno + "','"+record[i].isuse+"')\" onclick=\"selectedTr('" + record[i].id + "')\">");
                    else
                        arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED' style='cursor: pointer;'  ondblclick=\"ReturnValue('" + record[i].paperno + "','" + record[i].isuse + "')\" onclick=\"selectedTr('" + record[i].id + "')\">");

                }
                arr.push("<td height='20' class='STYLE6'>");
                arr.push("<input type='checkbox' name='checkbox_" + record[i].id + "' id='" + record[i].id + "' onclick=\"cbSelect(this, " + record[i].id + ")\"  />");
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].id);
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].paperno);
                arr.push("</td>");


                arr.push("<td height='20' class='STYLE6'>");
                if (record[i].isuse == "False")
                    arr.push("<font color='red'>未使用</font>");
                else
                    arr.push("已使用");
                arr.push("</td>");

                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].oprusername);
                arr.push("</td>");

                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].oprdate);
                arr.push("</td>");

                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].ownerusername);
                arr.push("</td>");

                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].usedate);
                arr.push("</td>");



                arr.push("</tr>");
            }
            arr.push("</table>");
            $("#divList").html(arr.join('')); // 显示列表
            $("#divPage").html(""); // 清空

            var pageHtml = LexunJS.showPage(currentPage, pageall, "showList"); // 分页
            $("#divPage").html(pageHtml);
        }

        // 全选
        function cbSelectAll() {
            document.getElementById("hID").value = "";

            var cbAll = document.getElementById("checkboxAll");
            var checkList = document.getElementsByTagName("input");

            if (cbAll.checked) {
                for (var i = 0; i < checkList.length; i++) {
                    if (checkList[i].type == "checkbox" && checkList[i].id > 0) {
                        checkList[i].checked = true;
                        if (parseInt(checkList[i].id) > 0) LexunJS.addOrCutData(1, "hID", checkList[i].id);
                    }
                }
            }
            else {
                for (var i = 0; i < checkList.length; i++) {
                    if (checkList[i].type == "checkbox" && checkList[i].id > 0) {
                        checkList[i].checked = false;
                        if (parseInt(checkList[i].id) > 0) LexunJS.addOrCutData(0, "hID", checkList[i].id);
                    }
                }
            }
        }

        // 单选
        function cbSelect(obj, objvalue) {
            if (obj.checked) {
                LexunJS.addOrCutData(1, "hID", objvalue);

            }
            else {
                LexunJS.addOrCutData(0, "hID", objvalue);
            }
        }

        // 选中某行
        function selectedTr(id) {
            $("tr").removeClass("selected");
            $("#tr_" + id).addClass("selected");
        }

        ///取看楼纸编号
        function ReturnValue(paperno, isUse) {
            if (isUse == "True") {
                alert("已使用的看楼纸不能取回，请重新选择！");
                return;
            }
            window.returnValue = paperno;
            window.close();
        }


        function Search() {
            var paparNo = $("#inputNo").val();

            if (paparNo == "") {
                alert("请输入看楼纸编号！");
                return;
            }

            var user_id = LexunJS.GetQueryString("userId");

            $("#divList").html("<img src=\"../images/loading.gif\" />"); // 清空列表
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerCustomer.ashx',
                data: 'act=ShowFloorPaper_list&page=' + currentPage + '&pagesize=' + pageSize + '&userId=' + user_id + '&paparNo=' + paparNo,
                timeout: '10000',
                error: function() {
                    alert("系统繁忙,请稍候后试！");
                }, success: function(json) {
                    listCallBack(json);
                }
            });

        }
        /*******************回收看楼纸**********************/
        function DeletePaparNo() {

            var IdList = $("#hID").val();

            if (IdList == "") {
                alert("请选择看楼纸！");
                return false;
            }
            // ajax删除
            hiConfirm("您确定要收回看楼纸，请谨慎！", "确认框", function(result) {
                if (result) {
                    $.ajax({
                        type: 'POST',
                        url: '../Handler/HandlerCustomer.ashx',
                        data: 'act=ShowFloorPaper_delete&IdList=' + IdList,
                        timeout: '10000',
                        error: function() {
                            alert("系统繁忙，请稍候再试！");
                        },
                        success: function(outmsg) {
                            alert(outmsg);
                            showList(currentPage);
                        }
                    });
                }
            });

        }

        
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <table border="0" cellspacing="0" cellpadding="3" style="margin-top: 10px; width: 100%;"
        bgcolor="#a8c7ce">
        <tr>
            <td style="background-color: #FFFFFF; text-align: center;">
                看楼纸编号：<input id="inputNo" type="text" />
                &nbsp;
                <input id="btnSearch" type="button" class="button_bak2" onclick="Search()" value=" 查 询 " />
                <input id="btnSave" type="button" visible="false" class="button_bak2" onclick="return DeletePaparNo();"
                    value=" 回收看楼纸 " />
                <font color="red">(找到相应的看楼纸后，双击取回楼盘信息)</font>
            </td>
        </tr>
        <tr>
            <td style="background-color: #FFFFFF; vertical-align: top;">
                <div id="divList">
                </div>
                <div id="divPage">
                </div>
            </td>
        </tr>
    </table>
    <input id="hID" type="hidden" />
    </form>
</body>
</html>
